package com.itcast.springbootenable;
import com.itcast.config.MyImportBeanDefinitionRegistrar;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Import;
import redis.clients.jedis.Jedis;
@SpringBootApplication
//1.@Import(UserConfig.class)  可以使用@Import注解，加载类。这些类都会被Spring创建，并放入IOC容器
//2.@ComponentScan("com.itcast.config") 使用@ComponentScan扫描com.itheima.config包
// 3.Enable//以对Import注解进行封装

/*  	import注解的四种用法
		*  	1. 导入Bean @Import(User.class)
		*  2. 导入配置类 @Import(UserConfig.class)
		*  3. 导入ImportSelector的实现类 @Import(MyImportSelector.class)
		*  4. 导入ImportBeanDefinitionRegistrar实现类 @Import(MyImportBeanDefinitionRegistrar.class)
		*/
@Import(MyImportBeanDefinitionRegistrar.class)
public class SpringbootEnableApplication {
	public static void main(String[] args) {
		ConfigurableApplicationContext context = SpringApplication.run(SpringbootEnableApplication.class, args);
		//Object user = context.getBean(User.class);1. 导入Bean @Import(User.class)
		//Object user = context.getBean(User.class);2. 导入配置类 @Import(UserConfig.class)
		//Object user = context.getBean(User.class);3. 导入ImportSelector的实现类 @Import(MyImportSelector.class)
		//Object user = context.getBean(User.class);4. 导入ImportBeanDefinitionRegistrar实现类 @Import(MyImportBeanDefinitionRegistrar.class)

		Jedis bean = context.getBean(Jedis.class);
		System.out.println(bean);

	}

}
